//
//  YHSortButton.m
//  SwiftProject
//
//  Created by qindong on 2021/5/18.
//

#import "SortButton.h"

@implementation SortButton

- (UIControlState)state
{
    UIControlState state = [super state];
    if (self.isSortUp) {
        state |= YHControlStateSortUp;
    }
    if (self.isSortDown) {
        state |= YHControlStateSortDown;
    }
    return state;
}

- (void)setSelected:(BOOL)selected
{
    super.selected = selected;
    if (!selected) {
        self.sortDown = NO;
        self.sortUp = NO;
    }
}

- (void)setSortUp:(BOOL)sortUp
{
    if (_sortUp != sortUp) {
        _sortUp = sortUp;
        if (sortUp) {
            self.selected = YES;
            self.sortDown = NO;
        }
    }
}

- (void)setSortDown:(BOOL)sortDown
{
    if (_sortDown != sortDown) {
        _sortDown = sortDown;
        if (sortDown) {
            self.selected = YES;
            self.sortUp = NO;
        }
    }
}

@end
